package com.huawei.videoservice.controller;




import com.huawei.videoservice.utils.MinioUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


@Tag(name = "video", description = "视频管理")
@RestController
@RequestMapping("/videos")
public class VideoController {

    @Autowired
    private MinioUtils minioUtils;

    @Operation(summary = "含有inner，前端无法调用")
    @GetMapping("/inner/{id}")
    public String getByIdInner(@PathVariable("id") Integer id){
        System.out.println("知行了video方法 " + id);
        return "video "+ id;
    }

    @Operation(summary = "测试-根据id查询视频")
    @GetMapping("/{id}")
    public String getById(@RequestHeader(name = "Authorization") String token, @PathVariable("id") Integer id){
        System.out.println("知行了video方法 " + id);
        return "video "+ id;
    }


    @Operation(summary = "上传视频")
    @PostMapping("/upload")
    public String uploadFile(@RequestHeader(name = "Authorization") String token,@RequestBody MultipartFile file) {
        String url = minioUtils.upload(file);
        //TODO: 保存到数据库
        return "success";
    }



}
